package si.yun.utils;


import org.apache.poi.ss.usermodel.DateUtil;
import org.springframework.util.CollectionUtils;
import si.yun.entity.SyCourse;

import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/*
 * @Description : 课程导入
 * @Return : 
 * @Date : 2021/9/8 10:28
 */public class OpcreateCoursePoi {

    //封装设备对象
    public static SyCourse createCoursePoi(List<String> list, HttpSession session){

        if(CollectionUtils.isEmpty(list)){
            return null;
        }

        SyCourse sc=new SyCourse();

        SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

        //后台用户id
        String userId=list.get(0);
        if(!userId.equals("")){
            double parseDouble = Double.parseDouble(userId);
            int userId2= (int) parseDouble;
            sc.setUserId(userId2);
        }

        //课程专业id
        String classId=list.get(1);
        if(!classId.equals("")){
            double parseDouble = Double.parseDouble(classId);
            int classId2= (int) parseDouble;
            sc.setClassId(classId2);
        }

        //推荐
        String recommend=list.get(2);
        if(!recommend.equals("")){
            double parseDouble = Double.parseDouble(recommend);
            int recommend2= (int) parseDouble;
            sc.setRecommend(recommend2);
        }

        //课程名称
        sc.setCourseName(list.get(3));

        //课程简介
        sc.setCourseIntro(list.get(4));


        //课程原价
        String coursePrice=list.get(5);
        if(!coursePrice.equals("")){
            double parseDouble = Double.parseDouble(coursePrice);
            int coursePrice2= (int) parseDouble;
            sc.setCoursePrice((long) coursePrice2);
        }

        //课程现价
        String courseNprice=list.get(6);
        if(!courseNprice.equals("")){
            double parseDouble = Double.parseDouble(courseNprice);
            int courseNprice2= (int) parseDouble;
            sc.setCourseNprice((long) courseNprice2);
        }

        //上架状态
        String courseStatus=list.get(7);
        if(!courseStatus.equals("")){
            double parseDouble = Double.parseDouble(courseStatus);
            int courseStatus2= (int) parseDouble;
            sc.setCourseStatus(courseStatus2);
        }

        //审核状态
        String courseCstatus=list.get(8);
        if(!courseCstatus.equals("")){
            double parseDouble = Double.parseDouble(courseCstatus);
            int courseCstatus2= (int) parseDouble;
            sc.setCourseCstatus(courseCstatus2);
        }

        //课程搜索关键字
        sc.setCoursePrimary(list.get(9));

        //图片封面url地址
        sc.setUrl(list.get(10));

        //课程url地址
        sc.setCourseUrl(list.get(11));

        //课程地址
        sc.setCourseInfo(list.get(12));

        //课程序号
        String courseNo=list.get(13);
        if(!courseNo.equals("")){
            double parseDouble = Double.parseDouble(courseNo);
            int courseNo2= (int) parseDouble;
            sc.setCourseNo(courseNo2);
        }

        //视频时长
        String courseTime=list.get(14);
        if(!courseTime.equals("")){
            double parseDouble = Double.parseDouble(courseTime);
            int courseTime2= (int) parseDouble;
            sc.setCourseTime(courseTime2);
        }

        //点赞数量
        String likeNum=list.get(15);
        if(!likeNum.equals("")){
            double parseDouble = Double.parseDouble(likeNum);
            int likeNum2= (int) parseDouble;
            sc.setLikeNum(likeNum2);
        }

        //分享数量
        String shareNum=list.get(16);
        if(!shareNum.equals("")){
            double parseDouble = Double.parseDouble(shareNum);
            int shareNum2= (int) parseDouble;
            sc.setShareNum(shareNum2);
        }

        //收藏数量
        String collectNum=list.get(17);
        if(!collectNum.equals("")){
            double parseDouble = Double.parseDouble(collectNum);
            int collectNum2= (int) parseDouble;
            sc.setCollectNum(collectNum2);
        }

        //预览数量
        String lookNum=list.get(18);
        if(!lookNum.equals("")){
            double parseDouble = Double.parseDouble(lookNum);
            int lookNum2= (int) parseDouble;
            sc.setLookNum(lookNum2);
        }

        //销售数量
        String saleNum=list.get(19);
        if(!saleNum.equals("")){
            double parseDouble = Double.parseDouble(saleNum);
            int saleNum2= (int) parseDouble;
            sc.setSaleNum(saleNum2);
        }

        //序号
        String sort=list.get(20);
        if(!sort.equals("")){
            double parseDouble = Double.parseDouble(sort);
            int sort2= (int) parseDouble;
            sc.setSort(sort2);
        }

        //创建人
        String createId=list.get(21);
        if(!createId.equals("")){
            double parseDouble = Double.parseDouble(createId);
            int createId2= (int) parseDouble;
            sc.setCreateId(createId2);
        }

        //创建时间
        String createDate=list.get(22);
        if(!createDate.equals("")) {
            double createDate2 = Double.parseDouble(createDate);
            Date d = DateUtil.getJavaDate(createDate2);
            sc.setCreateDate(d);
        }

        //更新人
        String updateId=list.get(23);
        if(!updateId.equals("")){
            double parseDouble = Double.parseDouble(updateId);
            int updateId2= (int) parseDouble;
            sc.setUpdateId(updateId2);
        }

        //更新时间
        String updateDate=list.get(24);
        if(!createDate.equals("")) {
            double updateDate2 = Double.parseDouble(updateDate);
            Date d = DateUtil.getJavaDate(updateDate2);
            sc.setUpdateDate(d);
        }

        //课程标签
        sc.setCourseLabel(list.get(25));

        return sc;
    }


}
